<template>
	<view>
		<bs-navbar :title='current==0?"会议信息":"会议统计"'></bs-navbar>
		<u-tabs active-color='#0050A5' inactive-color='#9A9A9A' :list="list" :is-scroll="false" :current="current" @change="change"></u-tabs>
		<bs-gap top="0" bottom="0"></bs-gap>
		<meetingMsg :activityGuestList='activityGuestList' :details='addDetails' v-if='current==0'></meetingMsg>
		<meetingStat :actNum='actNum' :tickList='tickList' :title='addDetails.title' :activityId='activityId' v-else></meetingStat>
	</view>
</template>

<script>
	import meetingMsg from './components/meetingMsg.vue'
	import meetingStat from './components/meetingStat.vue'
	export default {
		components: {
			meetingMsg,
			meetingStat
		},
		data() {
			return {
				list: [{
					name: '会议信息'
				}, {
					name: '会议统计'
				}],
				current: 0,
				activityId: '',
				addDetails: {},
				activityGuestList: [],
				paging: {
					page: 1,
					pageSize: 10,
					flag: 1,
					activityId: ''
				},
				pages: 0,
				tickList: [],
				actNum:{}
			};
		},
		onLoad(e) {
			this.activityId = e.activityId
			this.paging.activityId = e.activityId
			this.init()
		},
		async onReachBottom() {
			if (this.current == 1) {
				await this.getMore()
			}
		},
		methods: {
			async getMore() {
				if (this.pages == this.paging.page) {
					this.status = 'nomore';
					return
				}
				this.status = 'loading';
				this.paging.page = ++this.paging.page;
				let tickList = await this.$u.api.activityOfTicketList({
					...this.paging,
				})
				this.pages = tickList.pages
				this.tickList = this.tickList.concat(tickList.list)
				this.status = 'loadmore';
			},
			async init() {
				let res = await this.$u.api.addSetActivity({
					activityId: this.activityId
				})
				this.addDetails = res.activityTable
				this.activityGuestList = res.activityGuestList
				let actNum = await this.$u.api.activityTicketRestrict({
					activityId: this.activityId,
					flag: 1
				})
				this.actNum = actNum

				let tickList = await this.$u.api.activityOfTicketList(this.paging)
				// 
				this.pages = tickList.pages
				this.tickList = tickList.list
				if (this.pages == this.paging.page) {
					this.status = 'nomore';
				}
				console.log(this.tickList, '创建活动详情')
			},
			change(index) {
				this.current = index;
			},
		}
	}
</script>

<style lang="scss">

</style>
